home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
indeo
/
nwxmas
/
xd_play.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-05
|
2KB
|
100 lines
/*
** ╔══════════════════════════════════════════════════════════════╗
** ║ ║
** ║ Copyright (c) 1993 Digital Video Arts, Ltd. ║
** ║ All Rights Reserved ║
** ║ ║
** ╚══════════════════════════════════════════════════════════════╝
**
** Christmas card demo
**
** file: xd_video.c - loop the avss file
*/
#include <stdio.h>
#include <fcntl.h>
#include "nw.h"
#include "nwau.h"
#include "nwerrno.h"
#include "xmasdemo.h"
/*
** Ths AvDispatch array is used to tell NewWorld which hook routines
** are being provided by the programmer. In this case only one is
** provided, graphics(). It is to be called after the iamge has
** been decompressed
*/
static AvDispatchArray da = {
sizeof(AvDispatchArray),
P_Y, /* graphics only on Y plane */
0, /* not interested in data in */
0, /* for audio, video, or */
0, /* underlay */
0, /* don't care about before */
AvGraphics /* just after decompression */
};
PlayVideo()
{
AvDispatch(a, &da);
AvBind(a);
AvRead(a, 0L);
/*
** If the input has reached the end, seek to beginning and
** start again (only once per turn)
*/
if(a->in_frame >= a->framecnt-1) {
AvLSeek(a, 0L, SEEK_SET);
AvRead(a, a->framecnt);
}
return 0;
}
PlayAudio()
{
static int initialized = 0;
static int playcount = 0;
static long orglength;
static vobj v;
static int running;
static AudBlock loc;
if(playcount > 2) return 0;
if(!initialized) {
running = 0;
v.addr = AUDIOBUFFER;
v.size = FRAME_SIZE;
orglength = audiolength;
initialized = 1;
}
if(audiolength > 0) {
if ((AudChAlloc(channel, &v)) == 0)
return 0;
if((AudChWrite(channel, &v, &loc)) > 0)
AudChPlay(&loc);
else
return 0;
if(!running) {
AudChRun(channel);
running = 1;
}
v.addr += v.size;
audiolength -= v.size;
if(audiolength < v.size) v.size = audiolength;
}
if(audiolength == 0 && AudChDone(channel)){
audiolength = orglength;
v.addr = AUDIOBUFFER;
v.size = FRAME_SIZE;
++playcount;
}
return 0;
}